<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1>
        台账信息查询
    </h1>
</section>
<!--查看台账模态框-->
<div class="modal fade" id="modal-view">
    <div class="modal-dialog" style="width: 750px; height: 600px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">台账信息</h4>
            </div>
            <div class="modal-body">
                <table id="bootstrap-table-view"></table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>
                                        物料描述
                                    </label>
                                    <input type="text" id="ityMatName" name="ityMatName"
                                           class="form-control"
                                           placeholder="请输入物料描述">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>
                                        仓库
                                    </label>
                                    <select id="ityWhiId" name="ityWhiId" class="form-control">
                                        <option value="">全部</option>
                                        <option th:each="type:${warInfo}" th:value="${type.whiId}"
                                                th:text="${type.whiName}"></option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>字段名</label>
                                    <input type="text" id="imiField" name="imiField"
                                           class="form-control"
                                           placeholder="请输入字段名">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>值</label>
                                    <input type="text" id="imiValue" name="imiValue"
                                           class="form-control"
                                           placeholder="请输入值">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <button type="button" class="btn btn-vk" id="btn-search">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;搜索&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body" style="padding-top: 0px;">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>

<script th:inline="javascript">

    /**加载表格*/
    var table, table2;

    /**查看*/
    function viewLedger(id){
        js.modal.open("modal-view");
        js.post({
            url: ctx + "half/halInvManage/InvInfoEdit/view",
            data: {
                imiItyId: id
            },
            success: function (result) {
                js.table.load(table2, result.data.rows);
            }
        })
    }

    $(function () {

        /** 加载列表 */
        table = js.table.init({
            id: 'bootstrap-table',
            url: ctx + "half/halInvManage/InvInfoEdit/ledgerQueryList",
            pageSize: 300,
            showExport: false,
            columns: [
                {
                    title: '序号', field: 'ityId', width: '40',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '字段名', field: 'imiField'},
                {title: '值', field: 'imiValue'},
                {title: '台账单位', field: 'imiUnit'},
                {title: '物料描述', field: 'ityMatName'},
                {title: '数量', field: 'ityNum'},
                {title: '单位', field: 'ityUnit'},
                {title: '仓库', field: 'ityWhiIdName'},
                {title: '区位', field: 'ityPosition'},
                {title: 'SAP物料编码', field: 'itySapCode', width: '90'},
                {title: '图号', field: 'ityDrawingNumber'},
                {title: '操作',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (hasP("materialdictionary:edit")) {
                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="viewLedger(' + row.ityId + ')"> 查看</a>');
                        }
                        return actions.join('');
                    }
                }
            ]
        });
        table2 = js.table.init({
            id: 'bootstrap-table-view',
            firstLoad: false,
            showColumns: false,
            showExport: false,
            pageSize: 15,
            sidePagination: null,
            columns: [
                {
                    title: '序号', field: 'imiId', width: '40',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: '字段名', field: 'imiField'},
                {title: '值', field: 'imiValue'},
                {title: '台账单位', field: 'imiUnit'},
                {title: '物料描述', field: 'ityMatName'},
                {title: '数量', field: 'ityNum'},
                {title: '单位', field: 'ityUnit'}
            ]
        });
        /** 表格搜索 */
        $("#btn-search").click(function () {
            js.table.search(table);
        });

    })

</script>

</body>
</html>